package top.yxqz.springmvc.restful.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import top.yxqz.springmvc.restful.dao.EmployeeDao;
import top.yxqz.springmvc.restful.pojo.Employee;
import top.yxqz.springmvc.restful.service.EmployeeService;

import java.util.Collection;

/**
 * @author: 余小小
 * @date: 2023/5/4
 * @description：
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeDao dao;

    /*
    实现添加员工的操作
    1.判断该员工是否已经存在
        1.1如果存在，抛出异常
        1.2如果不存在，保存该员工
     */
    @Override
    public void save(Employee employee) {
        dao.save(employee);
    }

    @Override
    public Collection<Employee> getAll() {
        return dao.getAll();
    }

    @Override
    public Employee get(Integer id) {
        return dao.get(id);
    }

    @Override
    public void delete(Integer id) {
        dao.delete(id);
    }
}
